<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title>个人中心</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.css" rel="stylesheet" />
		<link href="../../css/style.css?100" rel="stylesheet" />
		<script src="../../js/flexible.js"></script>
		<script src="../../js/flexible_css.js"></script>
		<script src="../../js/jquery-1.9.1.min.js"></script>
		<script src="../../js/axios-proxy.js"></script>
		<script src="../../conf.js"></script>
		<script src="../../js/api.js"></script>
	</head>

	<body>
		<div class="personal" id="refreshContainer">
			<div class="personal-head">
				<h6 class="personal-head-name" id="headTruename">游客您好</h6>
				<div class="personal-info">
					<img src="" onclick="chooseHeadUrl()" id="headImage" onerror="javascript:this.src='../../images/head_code.png'"
					 alt="">
					<ul class="personal-income clearfix">
						<li>
							<span class="personal-income-num">1160</span>
							<span class="personal-income-msg">总收入</span>
						</li>
						<li>
							<span class="personal-income-num">1160</span>
							<span class="personal-income-msg">今日收入</span>
						</li>
						<li>
							<span class="personal-income-num">1160</span>
							<span class="personal-income-msg">已提现</span>
						</li>
					</ul>
				</div>
			</div>
			<!--中部-->
			<div class="personal-content">
				<ul class="personal-content-info" id="custom-nav">
					<li>
						<a href="../personal-data.html">
							<img class="personal-content-icon" src="../../images/icon_personaldata.png" alt="">
							<span class="personal-content-info-msg">个人资料</span>
						</a>
					</li>
					<li>
						<a href="">
							<img class="personal-content-icon" src="../../images/icon_team.png" alt="">
							<span class="personal-content-info-msg">我的团队</span>
						</a>
					</li>
					<li>
						<a href="../binding-bank-card.html">
							<img class="personal-content-icon" src="../../images/icon_bankcard.png" alt="">
							<span class="personal-content-info-msg">绑定银行卡</span>
						</a>
					</li>
					<li>
						<a href="">
							<img class="personal-content-icon" src="../../images/icon_wallet.png" alt="">
							<span class="personal-content-info-msg">钱包</span>
						</a>
					</li>
					<li>
						<a onclick="logout('./login.html')">
							<img class="personal-content-icon" src="../../images/icon_setup.png" alt="">
							<span class="personal-content-info-msg">设置(退出)</span>
						</a>
					</li>
				</ul>
			</div>
		</div>
		</div>
		<script src="../../js/mui.js"></script>
		<script type="text/javascript">
			mui.init({
				pullRefresh: autoRefresh('#refreshContainer', getQueryinfo, false)
			}); //主列表点击事件
			mui('#custom-nav').on('tap', 'li a', function() {
				var href = this.getAttribute('href');
				if (loginstate) {
					openwind(href)
				} else {
					openwind('../login.html');
				}
			});
			// 菜单
			function chooseHeadUrl() {
				if (mui.os.plus) {
					var btns = [{
						title: "拍照" //这些都是可以点击的选项的内容
					}, {
						title: "从手机相册选择"
					}];
					plus.nativeUI.actionSheet({
						title: "修改用户头像", //这里就是这个弹窗的title
						cancel: "取消", //取消按钮
						buttons: btns
					}, function(res) { /*actionSheet 按钮点击事件*/
						if (loginstate) {
							switch (res.index) {
								case 1:
									getImage(modifyheadCode);
									break;
								case 2:
									appendByGallery(modifyheadCode);
									break;
							}
						} else {
							loginfalse()
						}
					})
				}
			}
			// 上传
			function modifyheadCode(node) {
				var wt = plus.nativeUI.showWaiting();
				var task = plus.uploader.createUpload(uploadPhoto, {
						method: "POST"
					},
					function(t, status) { //上传完成
						if (status == 200) {
							mui.toast('上传成功')
							wt.close(); //关闭等待提示按钮
						} else {
							mui.toast('上传失败,请重试')
							wt.close(); //关闭等待提示按钮
						}
					}
				);
				//添加其他参数
				task.addData("phone", loginPhone);
				task.addFile(node, {
					key: "file"
				});
				task.start();
			}
			// 获取信息
			var num = 0;
			function getQueryinfo() {
				num++;
				if (loginstate) {
					getpersondata({
						phone: loginPhone
					}, function(res) {
						console.log(res.data.imageurl + '?' + new Date().getTime())
						$('#headImage').attr("src", res.data.imageurl + '?' + new Date().getTime());
						$('#headTruename').html(res.data.truename);
						if (num > 1){
							refreshContainer('#refreshContainer');
						}
					})
				} else {
					mui.toast('未登录');
					if (num > 1){
						refreshContainer('#refreshContainer');
					}
				}
			}
			getQueryinfo();
			backHome();
		</script>
	</body>

</html>
